package com.java.TestMyServerSocket;

import java.util.Vector;

public class ChatManager {

	private ChatManager(){}
	private static final ChatManager cm = new ChatManager();
	public static ChatManager getChatManager(){
		return cm;
	}
	Vector<ChatSocket> vestor = new Vector<ChatSocket>();

	public void add(ChatSocket cs){
		vestor.add(cs);
	}

	public void publish(ChatSocket cs,String out){
		for (int i = 0; i < vestor.size(); i++) {
			ChatSocket csChatSocket = vestor.get(i);
			if (!cs.equals(csChatSocket)) {
				csChatSocket.out(out);
			}
		}
	}
}
